package kr.co.spring329.sample.dao;

import java.util.List;

import kr.co.spring329.sample.model.ScheduleJobListVO;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class ScheduleJobListDao
{
	@Autowired
	private SqlSessionTemplate sqlSession;
	
	private String namespace = "kr.co.spring329.sample.mapper.schedulejoblist";
	
	/**
	 * 서버 호스트 네임 반환
	 * @return
	 * @throws Exception
	 */
	public String getServerHostName() throws Exception
	{
		System.out.println("***");
		return this.sqlSession.selectOne(String.format("%s.getServerHostName", this.namespace));
	}
	
	/**
	 * 서버 호스트 네임 업데이트
	 * @param hostName
	 * @throws Exception
	 */
	public int updateServerHostName(String hostName) throws Exception
	{
		return this.sqlSession.update(String.format("%s.updateServerHostName", this.namespace), hostName);
	}
	
	/**
	 * schedulejoblist 리스트 반환
	 * @return
	 * @throws Exception
	 */
	public List<ScheduleJobListVO> listJobList() throws Exception
	{
		return this.sqlSession.selectList(String.format("%s.listJobList", this.namespace));
	}
	
	/**
	 * cronExpression 업데이트
	 * @param scheduleJobListVO
	 * @return
	 * @throws Exception
	 */
	public int updateCronExpression(ScheduleJobListVO scheduleJobListVO) throws Exception
	{
		return this.sqlSession.update(String.format("%s.updateCronExpression", this.namespace), scheduleJobListVO);
	}
}



























